package com.hr.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hr.dao.PubinfoDao;
import com.hr.model.PubinfoModel;
import com.hr.model.UserModel;
import com.hr.service.PubinfoService;
/**
 * 公告管理
 * @author fazhen.zheng
 *
 */
@Service
public class PubinfoServiceImpl implements PubinfoService {
	@Autowired
	private PubinfoDao pubinfoDao;

	@Override
	public List<PubinfoModel> findAll() {
		return pubinfoDao.findAll();
	}
	/**
	 * 发布公告
	 */
	@Override
	public void addPubinfo(PubinfoModel pubinfoModel,UserModel user) {
		if(pubinfoModel!=null){
			//发布人
			pubinfoModel.setUser_id(user.getUser_id());
			//发布时间 
			// java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		     //String date = format1.format(new Date());
		     pubinfoModel.setTn_time(new Date());
		     pubinfoDao.insert(pubinfoModel);

		}
	}
	@Override
	public void delete(String id) {
		if(id!=null)
			pubinfoDao.delete(id);
	}
	@Override
	public PubinfoModel findById(String id) {
		if(id==null)
			return null;
		return pubinfoDao.findByPrimaryKey(id);
	}
}
